<template>
  <div class="news">
    <div class="header">
        <div class="image-1">
            <img src="../../../../static/img/logo_1.png" alt="">
        </div>
        <h2>新闻资讯</h2>
        <div class="image-2">
            <router-link to="/NewsDetails">
                <img src="../../../../static/img/right.png" alt="">
            </router-link>
        </div>
    </div>
    <div class="image-3">
        <router-link :to="{name:'NewsDetailsPage',params:{id:this.firstList.id}}">
            <img :src="this.firstList.cover" alt="">
        </router-link>
        <router-link :to="{name:'NewsDetailsPage',params:{id:this.firstList.id}}">
            <h3>{{this.firstList.title}}</h3>
        </router-link>
    </div>
    <div class="content">
        <div v-for="(newsLists, index) in newsList" :key= "index">
            <span class="bules"></span>
            <h3>
                <router-link :to="{name:'NewsDetailsPage',params:{id:newsLists.id}}">{{newsLists.title}}</router-link>
            </h3>
            <span class="long"></span>
        </div>   
    </div>
    <span></span>
  </div>
</template>
<script>
export default {
  name: 'News',
  data(){
      return {
          newsList: [],
          firstList: {}
      }
  },
  created(){
      this.axios.get('/articles/home',{
          params: {
              category: 1,
              limit: 4
          }
      })
      .then((res) => {
          this.newsList = res.data.data;
        //   this.newsList.unshift(res.data.meta.first);
          this.firstList = res.data.meta.first;
      })
      .catch((error) => {
          console.log(error);
      })
  }
}
</script>
<style scoped>
.news{
    width: 100%;
    height: auto;
    margin-top: .24rem;
}
.news .header{
    width: 100%;
    height: .53rem;
    line-height: .53rem;
}
.news .header .image-1{
    width: .53rem;
    height: .53rem;
    float: left;
    margin-left: .2rem;
}
.news .header .image-1 img{
    width: 100%;
    height: auto;
}
.news .header h2{
    font-size: .3rem;
    color: #1d2977;
    float: left;
    font-weight: bold;
}
.news .header .image-2{
    float: right;
    width: .32rem;
    height: .32rem;
    margin-right: .2rem;
    margin-top: .1rem;
}
.news .header .image-2 img{
    width: 100%;
    height: auto;
}
.news .image-3{
    width: 6.7rem;
    height: 3.89rem;
    margin: .43rem auto 0;
    position: relative;
    text-align: center;
}
.news .image-3 img{
    width: 100%;
    height: 3.89rem;
}
.news .image-3 h3{
    position: absolute;
    bottom: 0;
    height: .8rem;
    line-height: .8rem;
    background-color: rgba(195, 195, 195, 0.6);
    color: #fff;
    font-size: 14px; 
    width: 100%;
    overflow: hidden;
}
.news .content{
    width: 6.7rem;;
    height: auto;
    margin-left: .45rem;
}
.news .content div{
    margin-top: .2rem;
}
.news .content div h3{
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: .4rem;
}
.news .content div .bules{
    display: inline-block;
    width: 5px;
    height: 5.5px;
    border-radius: 25px;
    background-color: #1d2977;
    vertical-align: super;
}
.news .content div .long{
    width: 6.7rem;
    border-bottom: .02rem solid #e8e8e8;
    display: inline-block;
    margin-top: .2rem;
}
.news>span{
    display: inline-block;
    width: 100%;
    height: 0;
    border-bottom: .2rem solid #e8e8e8;
    margin-top: .6rem;
}
@media screen and (max-width: 320px) and (min-width: 320px) {
.news .content div h3{
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: .4rem;
}
.news .content div .bules{
    display: inline-block;
    width: 5px;
    height: 5.5px;
    border-radius: 25px;
    background-color: #1d2977;
    vertical-align: super;
}
}  
@media screen and (max-width: 414px) and (min-width: 414px) {
.news .content div .bules{
    display: inline-block;
    width: 5px;
    height: 5.5px;
    border-radius: 25px;
    background-color: #1d2977;
    vertical-align: text-top;
}
}  
@media screen and (max-width: 411px) and (min-width: 411px) {
.news .content div .bules{
    display: inline-block;
    width: 5px;
    height: 5.5px;
    border-radius: 25px;
    background-color: #1d2977;
    vertical-align: text-top;
}
}  
</style>
